package com.newMedical.qiantai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newMedical.common.annotation.Log;
import com.newMedical.common.core.controller.BaseController;
import com.newMedical.common.core.domain.AjaxResult;
import com.newMedical.common.enums.BusinessType;
import com.newMedical.qiantai.domain.HzUser;
import com.newMedical.qiantai.service.IHzUserService;
import com.newMedical.common.utils.poi.ExcelUtil;
import com.newMedical.common.core.page.TableDataInfo;

/**
 * 患者信息表Controller
 * 
 * @author zhou
 * @date 2022-03-25
 */
@RestController
@RequestMapping("/qiantai/user")
public class HzUserController extends BaseController
{
    @Autowired
    private IHzUserService hzUserService;

    /**
     * 查询患者信息表列表
     */
    @PreAuthorize("@ss.hasPermi('qiantai:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(HzUser hzUser)
    {
        startPage();
        List<HzUser> list = hzUserService.selectHzUserList(hzUser);
        return getDataTable(list);
    }

    /**
     * 导出患者信息表列表
     */
    @PreAuthorize("@ss.hasPermi('qiantai:user:export')")
    @Log(title = "患者信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HzUser hzUser)
    {
        List<HzUser> list = hzUserService.selectHzUserList(hzUser);
        ExcelUtil<HzUser> util = new ExcelUtil<HzUser>(HzUser.class);
        util.exportExcel(response, list, "患者信息表数据");
    }

    /**
     * 获取患者信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('qiantai:user:query')")
    @GetMapping(value = "/{hzId}")
    public AjaxResult getInfo(@PathVariable("hzId") Long hzId)
    {
        return AjaxResult.success(hzUserService.selectHzUserByHzId(hzId));
    }

    /**
     * 新增患者信息表
     */
    @PreAuthorize("@ss.hasPermi('qiantai:user:add')")
    @Log(title = "患者信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HzUser hzUser)
    {
        return toAjax(hzUserService.insertHzUser(hzUser));
    }

    /**
     * 修改患者信息表
     */
    @PreAuthorize("@ss.hasPermi('qiantai:user:edit')")
    @Log(title = "患者信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HzUser hzUser)
    {
        return toAjax(hzUserService.updateHzUser(hzUser));
    }

    /**
     * 删除患者信息表
     */
    @PreAuthorize("@ss.hasPermi('qiantai:user:remove')")
    @Log(title = "患者信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hzIds}")
    public AjaxResult remove(@PathVariable Long[] hzIds)
    {
        return toAjax(hzUserService.deleteHzUserByHzIds(hzIds));
    }
}
